package posecco.server;

import java.util.ArrayList;

import posecco.client.FieldService;
import posecco.client.Role;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.Query;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class FieldServiceImpl extends RemoteServiceServlet implements
		FieldService {
	
	public ArrayList<Role> roleFieldServer() throws IllegalArgumentException {

		try {
			ObjectifyService.register(Role.class);
		}
		catch (IllegalArgumentException e) {}
		ArrayList<Role> roleList = new ArrayList<Role>();
        Objectify ofy = ObjectifyService.begin();
        Query<Role> roleQuery = ofy.query(Role.class);
        for (Role role: roleQuery) {
            roleList.add(role);
        }
		return roleList;
	}
}
